<?php

namespace App\Http\Controllers;

use App\Record;
use Illuminate\Http\Request;

class RecordsController extends Controller
{
    public function index(Request $request)
    {
        $res = Record::where([])->orderBy('created_at', 'desc')->paginate($request->per_page??10);
        return response()->json(['success' => true, 'data' => $res]);
    }

    public function store(Request $request)
    {
        Record::create([
            'name' => $request->name,
            'tel' => $request->tel,
            'qq' => $request->qq
        ]);
        return response()->json(['success' => true, 'data' => '添加成功']);
    }
}
